package edu.jsnu.service.ticket.film.dto;

import edu.jsnu.service.ticket.film.domain.Film;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

import java.text.SimpleDateFormat;

@Getter
@Setter
public class FilmReceive {
    private Integer id;

    private String title;

    private String briefPic;

    private String description;

    private String kind;

    private String dimension;

    private String publish;

    private String online;

    private Integer duration;

    private String performer;

    private Integer sales;

    private Integer favor;

    private String remark;

    public static Film Receive2Film(FilmReceive receive){
        Film film = new Film();
        BeanUtils.copyProperties(receive, film);
        try {
            //转换日期格式
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            film.setPublishTime(sdf.parse(receive.getPublish()));
            film.setOnlineTime(sdf.parse(receive.getOnline()));
            return film;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static FilmReceive Film2Receive(Film film){
        FilmReceive receive = new FilmReceive();
        BeanUtils.copyProperties(film, receive);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        receive.setPublish(sdf.format(film.getPublishTime()));
        receive.setOnline(sdf.format(film.getOnlineTime()));
        return receive;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getBriefPic() {
        return briefPic;
    }

    public void setBriefPic(String briefPic) {
        this.briefPic = briefPic;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getKind() {
        return kind;
    }

    public void setKind(String kind) {
        this.kind = kind;
    }

    public String getDimension() {
        return dimension;
    }

    public void setDimension(String dimension) {
        this.dimension = dimension;
    }

    public String getPublish() {
        return publish;
    }

    public void setPublish(String publish) {
        this.publish = publish;
    }

    public String getOnline() {
        return online;
    }

    public void setOnline(String online) {
        this.online = online;
    }

    public Integer getDuration() {
        return duration;
    }

    public void setDuration(Integer duration) {
        this.duration = duration;
    }

    public String getPerformer() {
        return performer;
    }

    public void setPerformer(String performer) {
        this.performer = performer;
    }

    public Integer getSales() {
        return sales;
    }

    public void setSales(Integer sales) {
        this.sales = sales;
    }

    public Integer getFavor() {
        return favor;
    }

    public void setFavor(Integer favor) {
        this.favor = favor;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
